package com.yangye.springclouddemorocketmq.controller;

import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.core.ApplicationContext;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author yangye
 * @date 2020/07/15
 */
@RestController
public class ProducerController {

	@Resource
	private RocketMQTemplate rocketMQTemplate;

	@GetMapping("/send")
	public String send(String msg) {

		rocketMQTemplate.convertAndSend("test-topic", msg);
		return "success";
	}

//	@GetMapping("/pubsub/send")
//	public String pubsubSend(String msg) {
//
//	}

	public static void main(String[] args) {
		MockHttpServletRequest request = new MockHttpServletRequest();
		request.getServletContext().setAttribute("test", "111");
		System.out.println(request.getServletContext().getAttribute("test"));
	}
}
